package com.example.runtimepermissiontest;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;
import android.support.annotation.Nullable;

/**
 * Created by Administrator on 2018/1/24.
 */

public class MyProvider extends ContentProvider {

    public static final int TABLE1_DIR = 0;
    public static final int TABLE1_TIME = 1;
    public static final int TABLE2_DIR = 2;
    public static final int TABLE2_TIME = 3;

    private static UriMatcher uriMatcher;
    static {
        UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        uriMatcher.addURI("com.exaple.app.runtimepermissiontest","table1",TABLE1_DIR);
        uriMatcher.addURI("com.exaple.app.runtimepermissiontest","table1",TABLE1_TIME);
        uriMatcher.addURI("com.exaple.app.runtimepermissiontest","table2",TABLE2_DIR);
        uriMatcher.addURI("com.exaple.app.runtimepermissiontest","table2",TABLE2_TIME);
    }

    @Override
    public boolean onCreate() {
        return false;
    }

    @Nullable
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        switch (uriMatcher.match(uri)){
            case TABLE1_DIR:
                // 查询table1中的所有数据

                break;
            case TABLE1_TIME:
                // 查询table1中的单条数据

                break;
            case TABLE2_DIR:
                // 查询table2中的单条数据

                break;
            case TABLE2_TIME:
                // 查询table2中的单条数据

                break;
        }
        return null;
    }

    @Nullable
    @Override
    public String getType(Uri uri) {
        switch (uriMatcher.match(uri)){
            case TABLE1_DIR:
                // 查询table1中的所有数据
             
                break;
            case TABLE1_TIME:
                // 查询table1中的单条数据

                break;
            case TABLE2_DIR:
                // 查询table2中的单条数据

                break;
            case TABLE2_TIME:
                // 查询table2中的单条数据

                break;
        }
        return null;
    }

    @Nullable
    @Override
    public Uri insert(Uri uri, ContentValues values) {
        return null;
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        return 0;
    }
}
